package option;

import model.Author;
import model.GetAuthors_Optional;
import model.GetAuthors_Optional_null;

import java.util.Optional;

public class Get {
    public static void main(String[] args) {
        //封装的值不为null
        Optional<Author> author = GetAuthors_Optional.getAuthor();
        Author author1 = author.get();
        System.out.println(author1.getName()+"获取成功");
        //封装的值为null
        Optional<Author> author2 = GetAuthors_Optional_null.getAuthor();
        Author author3 = author2.get();
        System.out.println(author3.getName()+"获取成功");
    }
}
